//
//  HomeViewController.swift
//  wiboDemo
//
//  Created by shizb macbook air on 17/7/29.
//  Copyright © 2017年 YL. All rights reserved.
//

import UIKit
private let cellid="cellid"
class HomeViewController: WBBaseViewController {
    lazy var HomeViewModel = WBHomeViewModel()
    
    override func loadData() {
        HomeViewModel.getData(){_ in 
            print(self.HomeViewModel.homeList)
            self.refreshControl?.endRefreshing()
            self.tableView?.reloadData()

        };

        
    }
  
    func leftBtn() {
        let vc=DemoViewController()
        navigationController?.pushViewController(vc, animated: true)
    }
    
}
extension HomeViewController{
    override func setupUI() {
        super.setupUI()
       
        navItem.leftBarButtonItem=UIBarButtonItem(title: "下一个", fontSize: 12, taget: self, action: #selector(leftBtn))
        //注册cellid
        tableView?.register(UITableViewCell.self, forCellReuseIdentifier: cellid)
    }
}

extension HomeViewController{
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return HomeViewModel.homeList.count
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let Cell=tableView.dequeueReusableCell(withIdentifier: cellid, for: indexPath)
        Cell.textLabel?.text=HomeViewModel.homeList[indexPath.row].text
        return Cell
    }
}



















